using System;
using System.Collections.Generic;

namespace SmallMvc
{
    public class AllViews
    {
        private static readonly Type ViewType = typeof (SmallView);

        public static IEnumerable<Type> InTheSameAssemblyAs<T>()
        {
            return InTheSameAssemblyAsType(typeof (T));
        }

        private static IEnumerable<Type> InTheSameAssemblyAsType(Type archetype)
        {
            var types = archetype.Assembly.GetTypes();
            foreach (var type in types)
            {
                if (ViewType.IsAssignableFrom(type))
                {
                    yield return type;
                }
            }
        }
    }
}